
#import "LLWelComeViewController.h"
#import "LLTabBarController.h"
@interface LLWelComeViewController ()
@property (weak, nonatomic) IBOutlet UILabel *welLab;
@property (weak, nonatomic) IBOutlet UIImageView *iconImage;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *iconConstraintY;

@end

@implementation LLWelComeViewController

- (void)viewDidLoad{
    
    [super viewDidLoad];
    
    self.iconImage.layer.cornerRadius = 42.5;
    self.iconImage.layer.masksToBounds = YES;
    
    LLAccount *account = [LLAccountTool readInShaHe];
    NSURL *iconUrl = [NSURL URLWithString:account.profile_image_url];
    SDWebImageManager *mgr = [SDWebImageManager sharedManager];
    [mgr downloadImageWithURL:iconUrl options:SDWebImageHighPriority progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) {
        if (finished) {
            
            self.iconImage.image = image;
        }
    }];
}

- (void)viewDidAppear:(BOOL)animated{
    
    [super viewDidAppear:animated];
    
    [UIView animateWithDuration:1.0 animations:^{
        
        self.iconConstraintY.constant += 130;
        [self.view layoutIfNeeded];
    } completion:^(BOOL finished) {
        
        [UIView animateWithDuration:2.0 animations:^{
              self.welLab.alpha = 1.0;
            
        } completion:^(BOOL finished) {
            
            LLTabBarController *tabbarVc = [[LLTabBarController alloc] init];
            // 2.切换根控制器
            UIWindow *window = [UIApplication sharedApplication].keyWindow;
            window.rootViewController =  tabbarVc;
            
        }];

    }];
}

@end
